package controle;

import gui.ChatVoxGui;

import java.io.ObjectInputStream;
import java.net.Socket;


public class IniciaConexaoChatHandler extends Thread{
	public Socket conexao;
	private ControlePortas controlePortas;
	private ChatVoxGui chatVoxGui;
	
	public IniciaConexaoChatHandler( Socket conexao, ChatVoxGui chatVoxGui){
		this.conexao = conexao;
		this.chatVoxGui = chatVoxGui;
	}
	
	public void run()
	{
		try
		{   
			ObjectInputStream oi = new ObjectInputStream(conexao.getInputStream());   
			this.controlePortas = (ControlePortas) oi.readObject();
			System.out.println("this.controlePortas.getPortaSaida(): " + this.controlePortas.getPortaSaida());
			System.out.println("this.controlePortas.getPortaEntrada(): " + this.controlePortas.getPortaEntrada());
			this.chatVoxGui.initListener(this.controlePortas);
			this.chatVoxGui.setVisible(true);
			this.chatVoxGui.setEnabled(true);
						
			conexao.close(); 
		}
		catch(Exception e){  
			e.printStackTrace();  
			System.exit(1);  
		}  
	}
}
